package com.btr.ivle.helper;

import java.util.Comparator;
import java.util.Map;

public class MapComparator implements Comparator<Map<String, String>>{
	
	private String sortBy;
	private boolean asc;
	
	public MapComparator(String sortBy, boolean asc){
		this.sortBy = sortBy;
		this.asc = asc;
	}

	public int compare(Map<String, String> m1, Map<String, String> m2) {
        if(asc)
        	return m1.get(sortBy).compareTo(m2.get(sortBy));
        else
        	return m2.get(sortBy).compareTo(m1.get(sortBy));
    }
}
